package com.dinetech.dao;

import java.util.ArrayList;

import com.dinetech.ejecutor.R;
import com.dinetech.entidades.Evento;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ItemEventoAdapter extends BaseAdapter {

	private Activity activity;
	private ArrayList<Evento> items;
	
	public ItemEventoAdapter(Activity activity, ArrayList<Evento> items){
		this.activity = activity;
		this.items = items;
	}
	
	@Override
	public int getCount() {		
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return items.get(position).getIdEvento();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		
		if(convertView == null) {
        	LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        	vi = inflater.inflate(R.layout.evento_list_item, null);
        }
            
        Evento item = items.get(position);        
        
        TextView nombEvento = (TextView) vi.findViewById(R.id.txtnombreEvento);
        nombEvento.setText(item.getNombreEvento());
                        
        return vi;

	}

}
